package top.goldenyear.porpoise.system.auth.service;

import com.easy.query.api.proxy.client.EasyEntityQuery;
import com.easy.query.solon.annotation.Db;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Component;
import top.goldenyear.porpoise.framework.web.core.model.PageResult;
import top.goldenyear.porpoise.framework.web.core.model.query.QPage;
import top.goldenyear.porpoise.framework.web.core.service.BaseService;
import top.goldenyear.porpoise.system.auth.model.LoginLog;
import top.goldenyear.porpoise.system.auth.model.proxy.LoginLogProxy;

/**
 * 登录日志表 Service 服务层
 *
 * @author airhead
 * @since 2024-10-12
 */
@Component
@Slf4j
public class LoginLogService extends BaseService<LoginLog, LoginLogProxy> {
  @Db private EasyEntityQuery easyEntityQuery;

  public LoginLogService() {
    super(LoginLog.class, LoginLogProxy.class);
  }

  public Boolean createLoginLog(LoginLog loginLog) {
    return save(loginLog);
  }

  public Boolean updateLoginLog(LoginLog loginLog) {
    return updateById(loginLog);
  }

  public LoginLog getLoginLog(Integer id) {
    return getById(id);
  }

  public Boolean deleteLoginLog(Integer id) {
    return deleteById(id);
  }

  public List<LoginLog> listLoginLog(LoginLog loginLog) {
    return list(loginLog);
  }

  public PageResult<LoginLog> paginateLoginLog(QPage qPage, LoginLog loginLog) {
    return paginate(qPage.getPageNumber(), qPage.getPageSize(), loginLog);
  }

  @Override
  protected EasyEntityQuery easyEntityQuery() {
    return easyEntityQuery;
  }
}
